<html>
	<head>
	
	<modalbox:modalIncludes />
	
	<script type="text/javascript">
	    function ChangeColor(tableRow, highLight)
	    {
	    if (highLight)
	    {
	      tableRow.style.backgroundColor = '#CCCCCC';
	    }
	    else
	    {
	      tableRow.style.backgroundColor = '#FFFFFF';
	    }
	  }
	
	  function DoNav(theUrl)
	  {
	  document.location.href = theUrl;
	  }

	  function EditMun(id) {
		  document.location.href = "/SEDH-PROJECT/municipio/edit/"+id;
	   }

	  function showSpinner(visible) {
	         $('spinner').style.display = visible ? "inline" : "none";
	     }
	     Ajax.Responders.register({
	     onLoading: function() {
	           showSpinner(true);
	     },
	     onComplete: function() {
	     if(!Ajax.activeRequestCount) showSpinner(false);
	     }
	   });

	  </script>
	  
    <g:render template="/header"/>
    </head>
    
    <body class="body" onload="pageLoaded();">
	
	<g:render template="/informationBar"/>
    
    <g:render template="/menu"/>
    
    <div class="mainContent">
    
    <div class="searchDiv">
     <h1>Pesquisa de Municipio:</h1>
     <g:remoteField class="searchBox" name="search" paramName="searchvalue" update="searchresult" value=""
     							url="[controller:'municipio', action:'searchMunicipio']"
                                  onLoading="showSpinner(true);" onComplete="showSpinner(false);">
    </g:remoteField>
   	</div>
    
	
   	<div class="tableRowGroup">
   	
   	<g:render template="searchResult" var="searchresults" bean="${municipioInstanceList}"/>
   	
	<div>
	<h1>Informacao do Municipio:</h1>
	Nome: ${fieldValue(bean: municipioInstance, field: "nome")}</br>
	Habitantes: ${fieldValue(bean: municipioInstance, field: "habitantes")}</br>
	</br>
	</div>
	<div class="table">
	
	<div class="tableCell">
	
	<b>Servicos:<p></b>
	<g:each in="${servicosList}" status="i" var="servicoAtual">
		<div>
			${fieldValue(bean: servicoAtual.getAt("servico"), field: "nome")}
		</div>		
    </g:each>
    
    <div>
    <a href="${createLink(controller:'alocadorMunSer',action:'createbymun',params:[muni:fieldValue(bean: municipioInstance, field: "nome").toString()] )}" >Alocar para Servico</a>
    </div>
    </div>
    
    <div class="tableCell">
	<b>Programas:</b>
	<g:each in="${programasList}" status="i" var="programaAtual">
		<div>
			${fieldValue(bean: programaAtual.getAt("programa"), field: "nome")}
		</div>
    </g:each>
    
    <div>
    <a href="${createLink(controller:'alocadorMunProg',action:'createbymun',params:[muni:fieldValue(bean: municipioInstance, field: "nome").toString()] )}" >Alocar para Programa</a>
    </div>
	</div>
	
	</div>
	

	</div>
	
	</div>
	
   <g:render template="/foot"/>

    </body>
    

</html>